﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Configuration;

namespace RecruitmentProcessSystem
{
    public partial class frmViewInterview : Form
    {

        String conStr = ConfigurationManager.ConnectionStrings["conStr"].ConnectionString;
        SqlConnection conn;
        SqlCommand cmd;
        SqlDataAdapter da;
        DataSet ds;
        public frmViewInterview()
        {
            InitializeComponent();
        }

        private void frmViewInterview_Load(object sender, EventArgs e)
        {
            ds = new DataSet();
            conn = new SqlConnection(conStr);
            conn.Open();
            cmd = new SqlCommand("Select * from Interview", conn);
            da = new SqlDataAdapter(cmd);
            da.Fill(ds, "Interview");
            dataGridView1.DataSource = ds.Tables[0];
            conn.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {   
            try{

            if (cbxSearch.SelectedItem.ToString() == "Tìm kiếm theo người phỏng vấn")
            {
                ds.Tables[0].DefaultView.RowFilter = "interviewer like\'%" + txtInterviewer.Text + "%\'";
            }
            else if (cbxSearch.SelectedItem.ToString() == "Tìm kiếm theo ứng viên")
            {
                ds.Tables[0].DefaultView.RowFilter = "aname like\'%" + txtInterviewer.Text + "%\'";
            }
            else if (cbxSearch.SelectedItem.ToString() == "Tìm kiếm theo vị trí")
            {
                ds.Tables[0].DefaultView.RowFilter = "vname like\'%" + txtInterviewer.Text + "%\'";
            }
            else if (cbxSearch.SelectedItem.ToString() == "Tìm kiếm theo trạng thái")
            {
                ds.Tables[0].DefaultView.RowFilter = "istatus like\'%" + txtInterviewer.Text + "%\'";
            }
            }
            catch
            {
                ds.Tables[0].DefaultView.RowFilter = "interviewer like\'%" + txtInterviewer.Text + "%\'";
            }
        }

        private void btnReport_Click(object sender, EventArgs e)
        {
            frmReportInterview frm = new frmReportInterview();
            frm.Show();
        }
    }
}
